#include<bits/stdc++.h>
using namespace std;

bool mycmp(char c1, char c2)
{
	return c1 < c2;
}

int main()
{
	string str, strx;
	cin >> str;
	strx = str;
	sort(str.begin(), str.end());
	int ans = 0;
	do
	{
		if(strx == str)
			break;
		ans++;
	}while(next_permutation(str.begin(), str.end()));
	cout << ans << endl;
}
